 const {
     validationResult,
     check,
     checkSchema
 } = require('express-validator');

 checkArgsEmpty = function (arr, ...rest) {
     arr = arr.map(v => check(v).notEmpty());
     return [...arr, ...rest];
 };

 module.exports = {
     //错误参数处理
     validErrMsg(req, res, next) {
         let validRes = validationResult(req);
         if (!validRes.isEmpty()) { //存在验证错误的字段
             let msg = validRes.errors.map(v => `${v.param}`); //遍历获取错误字段
             return res.status(400).json({
                 statusCode: 400,
                 msg: msg.join(',') + ' 请检查'
             });
         }
         next();
     },
     checkArgsEmpty,
     check,
     checkSchema
 }